define(function(require){
	var main =require('/static/main.js');
	var m = new main();
	function Cont(){
		this.Fun._init();
	}
	Cont.prototype.Fun = {
		_init:function(){
		    this.getlist();
			this.bindEvent();
		},
		bindEvent:function(){
			
		},
		getlist:function(){
	        var param = {};
	        var table1 = $('#datatable').dataTable({
	        	'ordering':false,
	        	"serverSide": true,
	        	"searching":false,
	        	'bLengthChange': false,
	        	ajax: function (data, callback, settings) {
	                param.PageSize = data.length;
	                param.start = data.start;
	                param.PageNo = (data.start / data.length)+1;
	                $.ajax({
	                    type: "POST",
	                    url: "/subordinate/subordinate-list",
	                    cache: false,  
	                    data: param, 
	                    dataType: "json",
	                    success: function (result) {
                    	    var returnData = {};
                            returnData.draw = data.draw;
                            returnData.recordsTotal = result.total;
                            returnData.recordsFiltered = result.total;
                            returnData.data = result.data;
                            callback(returnData);
	                    }
	                });
	            },
				"aoColumns":[
					{
						"mDataProp": 'Name',
						render:function(data){
							return data ? data : ''
                    	}
					}, 
					{
						"mDataProp": 'Phone',
					}, 
                    {
                    	"mDataProp": 'MonthScore',
                    	render:function(data){
							return data ? data : 0
                    	}
                   	},
                   	{
                    	"mDataProp": 'TotalScore',
                    	render:function(data){
							return data ? data : 0
                    	}
                   	},
                    {
                    	"mDataProp": 'CreateTime',
                    	render:function(data){
                    		if(data){
                    			return m.formatTimeAll2(data)
                    		}else{
                    			return '';
                    		}
                    	}
                	},
                    {
			            "mDataProp": "MytipId",
			            "sClass": "option_btn",
			            "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
			            	console.log(arguments);
			                $(nTd).html('<div data-toggle="modal" data-target="#con-close-modal" style="display: inline-block;">\
                                                  <a href="/subordinate/detail?id='+sData+'"><span class="btn_detial" >查看</span></a>\
                                                </div>');

			            }
			        }
				],
	        }).api();
			// 点击搜索
	        $('#btnSearch').click(function(){
	        	param.Phone = $('.Phone').val();
	        	param.TrueName = $('.TrueName').val();
	        	param.StartTime = $('.StartTime').val()
	        	param.EndTime = $('.EndTime').val()
                table1.ajax.reload();
	        })
	        // 点击重置按钮
	        $('#btnRefresh').click(function(){
	        	$('.Phone').val('');
	        	$('.TrueName').val('');
	        	$('.StartTime').val('');
	        	$('.EndTime').val('');
	        })
		},

	}
	var a = new Cont();

})